#!/usr/bin/env python

''' A Parser for the Dandy language

See http://code.google.com/p/dandy for the language specs
'''

from tokenizer import tokenize

def parse(document):
  '''Converts a document to production functions'''
  return []

def main():
  lines = ['%toc auto',
           ' ',
           '%h1 Sample document',
           ' ',
           'This is going to be normal paragraph text',
           'Doncha kno',
           'But this will be way way cooler than that',
           '%interestingly enough the parser should treat',
           'all of these lines as text in the same paragraph',
           'because empty lines distinguish paragraphs',
           '',
           'So this should create a new paragraph'
           '',
           '%h2 Now we switched to command mode',
           '%* While in command mode you can',
           '%*2 Do fairly cool things like this',
           '%** Though I\'m debating if notation like this is better than numbered',
           '%*** I like both ways, though *** feels more natural... interesting',
           'Entering text puts us back in text mode',
           'So now that we\'re in text mode we\'ll stop procesing commands',
           '%is that confusing? I hope not',
           ]
  document = '\n'.join(lines)
  print document
  
  for line in lines:
    print tokenize(line)
  
  text='%embed youtube url=r"http://youtube.com/something?somethingelse"caption text'
  print tokenize(text)

if __name__ == '__main__':
  main()
